home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1993 May
/
Info-Mac_II_May_1993.to_.sit
/
Info-Mac II (May 1993).toast
/
Unix
/
Get Sumex Files.txt
< prev
next >
Wrap
Internet Message Format
|
1992-08-29
|
5KB
Date: Tue, 19 Mar 91 12:26:40 EST
From: Tom Coradeschi <tcora@pica.army.mil>
Subject: Sumex & FTP
Some folks on comp.sys.mac.comm have been enquiring about how to do ftp
sessions with sumex, now that the 25 user limit has been imposed. The obvious
solution is to run your ftp session at 5AM Pacific, but for left-coasters,
and many of us to the east, that's a little difficult.
One solution is to run your ftp session via a script. The following is
one I've been using for a long time, and it seems to work quite well.
In order to make the script capable of autonomously logging in (without
your being there to give username and password), you need a '.netrc' file
in your home directory. This file should have read and write permissions for
the user only (chmod 600 .netrc), and be of the following format:
machine sumex-aim.stanford.edu, login anonymous, password user@host.site.dom
Fill in your own email address for the password.
In order to run the shellscript during off hours, you can use one of these
two methods (and I'm sure there are others).
The first is to have the shellscript "sleep" for a given number of hours
(seconds, actually). Let's say that it's 5PM, and you want the script to run
at 2AM. 5PM->2AM= 9 hrs = 32,400 seconds. So, you type:
(sleep 32400;sumex.get)&
Where the sleep 32400 command waits for 9 hrs, and sumex.get is the name
of your shellscript. The & character is the Cshell command to run the
process in the background. If you run bourne shell or k shell or whatever,
you'll have to dig around for the appropriate command to do that. The ;
separator tells your shell environment to run the commands sequentially, so
after 32,400 seconds, sumex.get executes, and (hopefully) gets you your
files.
The second method is to use the "at" command. Here, the syntax is a
little simpler, but you must be sure that at runs on your system. Again,
there may be an equivalent command on your particular system. Simply type:
at 0200 sumex.get
At 0200 hrs (2AM) sumex.get will execute.
OK. On to the scripts. There are two files I'm including here, where one
is the script and the other is the input file it looks for. In this case,
I'm calling them sumex.get and sumex.files. Determining which is the script
and which is the input file is left as an exercise for the reader:-}
The shellscript does the following: It ftps to sumex, and tries to get
the files called for in sumex.files. If it cannot successfully complete the
ftp session, ie, some sort of an error is reported, that error is written to
the errors file. The script checks on the size of the errors file, and if
that file has size > 0, then it waits the interval you've designated, and
tries the ftp session again.
====file sumex.get====
#!/bin/sh
# Shell script to try repeatedly to get files via ftp from the host named
# below. The host is repeatedly polled until the session is successfully
# completed.
# This is the site we're ftp'ing to.
host=sumex-aim.stanford.edu
# Define the input, result and error files.
in=sumex.files
out=$host.results
err=$host.errs
# How long to sleep between subsequent tries (in seconds):
#time=600 # Ten minutes
time=3600 # An hour
#time=7200 # Two hours
echo "Starting to get files from $host." > $out
# Try to make connection w/out error loop first time
# Initialize the error message file so we start the loop:
echo "Trying to reach $host at time:" >> $out
date +'%H:%M hrs; %d %h %y' >> $out
ftp $host < $in >> $out 2> $err
# MAIN LOOP: If error file isn't empty, we sleep for an hour and try again.
while test -s $err
do
echo "Cannot connect now, will try again in $time seconds." >> $out
sleep $time
echo "Trying to reach $host at time:" >> $out
date +'%H:%M hrs; %d %h %y' >> $out
ftp $host < $in >> $out 2> $err
done
echo "File transfer successful!" >> $out
====end sumex.get====
The input file merely contains the commands you would type in, if you
were doing this manually. Make sure!! that you include the quit command on
the last line.
====file sumex.files===
cd info-mac/card
get el-verbo-simple.hqx
cd ../init
get randomizer.hqx
quit
====end sumex.files====
I hope that my explanation has been clear enough. Really all you should
have to do is to edit out all my bs and save the two files off separately.
Make sure that the shellscript is executable ('chmod 744 sumex.get' should do
it), and off you go...
tom coradeschi <+> tcora@pica.army.mil <+> tcora@dacth01.bitnet
PS: If your system doesn't run some sort of unix (UNIX, A/UX, SunOS, etc),
all bets are off.